<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>患者列表-医嘱</title>
		<link rel="stylesheet" type="text/css" href="../lib/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="../css/hzgl.css" />
		<link rel="stylesheet" type="text/css" href="../css/reset.css" />
	</head>
	<body>
		<div class="container">
			<div class="layui-tab layui-tab-brief" lay-filter="demo">
				<ul class="layui-tab-title">
					<li class="layui-this">出科</li>
					<li>在科</li>
					<!-- 	<span class="shuaxin">刷新</span>
					<a href="">刷新</a> -->
					<!-- <div class="shuaxin">刷新</div> -->
				</ul>

				<!-- 条件查找 -->
				<div class="layui-form find">
					<div class="layui-form-item">
						<label class="layui-form-label">住院号:</label>
						<div class="layui-input-block">
							<input type="text" name="num" placeholder="请输入关键字" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">病人姓名:</label>
						<div class="layui-input-block">
							<input type="text" name="name" placeholder="请输入关键字" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item" style="margin-left: 20px;">
						<button type="button" class="layui-btn" lay-submit="" lay-filter="findhz">查询</button>
						<button type="button" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
				<div id="view" class="view clearfix"></div>
				<div id="test1"></div>
				<!-- <div class="layui-tab-content clearfix">
					<div class="layui-tab-item layui-show">
						<div class="card fl">
							
						</div>
					</div>
					<div class="layui-tab-item">
						<div class="card fl">
							
						</div>
					</div>
				</div> -->
			</div>

		</div>

	</body>

	<!-- 模板渲染 -->
	<script id="demo" type="text/html">
		{{#  layui.each(d, function(index, item){ }}
		  <div class="item" value="{{item.bedCode}}">
		  <a href="./searchlist.html?patientId={{item.patientId}}&patName={{item.patName}}&admid={{item.admid}}">
			<div class="tit">
			<span>{{item.patSex}}</span>
			<!-- 床号 -->
			<span class="ch">{{item.bedCode}}</span>
			<!-- 姓名 -->
			<span class="name">{{item.patName}}</span>
			<!-- 年龄 -->
			<span class="bh">{{item.patAge}}</span>
			<!-- 护理等级 -->
			<span class="hldj">{{item.nursingLevel}}</span>
			</div>
			<div class="con clearfix">
				<div class="fl w55">
					<ul>
						<li><span>住院号：{{ item.admid }}</span></li>
						<li><span>入院：{{ item.admDate }}</span></li>
						<li><span>医生：{{ item.mainDoctor }}</span></li>
						<li><span>诊断：{{ item.diatag  }}</span></li>
					</ul>
				</div>
				<div class="fl w45">
					<ul>
						<li><span>总缴费：{{ item.total }}</span></li>
						<li><span>余额：{{ item.balance }}</span></li>
						<li><span>医保方式：{{ item.medicalType  }}</span></li>
					</ul>
				</div>
			</div>
			<div class="foot">
				<span>{{ item.illnessState }}</span>
			</div>
			</a>
			</div>
		  {{#  }); }}
		  {{#  if(d.length === 0){ }}
			无数据
		  {{#  } }}  
	</script>
	<script src="../js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/global.js" type="text/javascript" charset="utf-8"></script>
	<!-- <script src="../js/hzgl.js" type="text/javascript" charset="utf-8"></script> -->
	<script src="../js/common.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		layui.use(['laypage','form','element', 'laytpl'], function() {
			var laytpl = layui.laytpl;
			var element = layui.element;
			var laypage = layui.laypage;
			var form = layui.form;
			
			//监听submit
			form.on('submit(findhz)', function(data) {
				console.log(data.field);
				
				return false;
			});
			
			// 默认参数
			var isHospital = "0";//不在科
			var page = "1";
			var wardId = getUser().wardId;

			
			// 监听tab
			element.on('tab(demo)', function(data) {
				isHospital = data.index;
				console.log(isHospital);
				getPatientline(isHospital,page);
			});
			
			function getPatientline(isHospital,page){
				// 请求参数
				var param = JSON.stringify({
					"body": {
						"isHospital": isHospital,
						"departmentId": wardId,
						"currPage":page,
						"patientName": "",
						"admid": ""
					},
					"header": {},
					"token": {}
				});
				$.ajax({
					'type': 'post',
					'url': '/service-patient/patient/viewPatientList',
					'data': param,
					'dataType': 'json',
					'contentType': "application/json",
					'success': function(data) {
						console.log(data);
						var len = data.data.total;
						var pageNum = data.data.pageNum;
						var list = data.data.list;
						
						laypage.render({
							elem: 'test1',
							count: len, //数据总数，从服务端得到
							curr: pageNum, //起始页
							// groups: 5,
							limit: 10,
							// limits:[8],
							layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
							jump: function(obj, first) {
								//obj包含了当前分页的所有参数，比如：
								console.log("当前页码" + obj.curr); //得到当前页，以便向服务端请求对应页的数据。
								console.log("当前显示" + obj.limit + "条"); //得到每页显示的条数
									//根据当前页请求和渲染模
								// thisData = list.concat().splice(obj.curr*obj.limit - obj.limit, obj.limit);
								// console.log(thisData);	
								page = obj.curr
								var getTpl = demo.innerHTML,
									view = document.getElementById('view');
								laytpl(getTpl).render(list, function(html) {
									view.innerHTML = html;
								});
									
								//首次不执行
								if (!first) {
									//do something
									getPatientline(isHospital,page);
								}
							}
						});
					},
					'error': function(res) {
						console.log(res);
					}
				});
			}
			
			getPatientline(isHospital,page);
			
			
		})
	</script>
</html>

